package active.commond.invoker;

import active.commond.concretecommond.ICommond;
import active.commond.concretecommond.LightOffCommond;
import active.commond.concretecommond.LightOnCommond;
import active.commond.concretecommond.NoCommond;
import active.commond.reciver.LightReciver;

/**
 * 3个按钮  一个开灯, 一个关灯, 一个撤销
 */
public class RemoteInvoker {

    private ICommond commondOn;
    private ICommond commondOff;
    private ICommond commondUndo;

    public RemoteInvoker(LightReciver lightReciver) {
        commondOn = new LightOnCommond(lightReciver);
        commondOff = new LightOffCommond(lightReciver);
        commondUndo = new NoCommond();
    }

    public void pressButtonLightOn() {
        commondOn.execute();
        commondUndo = commondOn;
    }

    public void pressButtonLightOff() {
        commondOff.execute();
        commondUndo = commondOff;
    }

    public void undo() {
        commondUndo.undo();
    }

}
